/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.crystalrange.softwares.service.impl;

import com.googlecode.genericdao.search.Search;
import com.googlecode.genericdao.search.SearchResult;
import java.util.Date;
import java.util.List;
import org.crystalrange.model.User;
import org.crystalrange.service.UserService;
import org.crystalrange.softwares.dao.SoftwareDao;
import org.crystalrange.softwares.model.Software;
import org.crystalrange.softwares.service.SoftwareService;

/**
 *
 * @author Krzysiek
 */
public class SoftwareServiceImpl implements SoftwareService {
    
    private SoftwareDao softwareDao;
    private UserService userService;

    public SoftwareDao getSoftwareDao() {
        return softwareDao;
    }

    public void setSoftwareDao(SoftwareDao softwareDao) {
        this.softwareDao = softwareDao;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }
    
    public Software create(String username) {
        User currentUser = this.userService.findByUsername(username);   
        
        Software software = new Software();
        software.setCreatedBy(currentUser);
        software.setCreatedDate(new Date());
        
        return software;
    }

    public boolean save(Software software) {
        return this.softwareDao.save(software);
    }

    public boolean remove(Software software) {
        return this.softwareDao.remove(software);
    }

    public Software find(Long id) {
        return this.softwareDao.find(id);
    }

    public List<Software> findAll() {
        return this.softwareDao.findAll();
    }

    public SearchResult<Software> searchAndCount(Search search) {
        return this.softwareDao.searchAndCount(search);
    }

    public List<Software> search(Search search) {
        return this.softwareDao.search(search);
    }

    public Software searchUnique(Search search) {
        return this.softwareDao.searchUnique(search);
    }
    
}
